<div class="row m-n">
    <div class="crumbs-bar">
        <div yb-crumbs></div>
    </div>
    <div tabset type="tab">
        <div tab heading="兑换订单" active="activeFlag[0]" ng-click="changeTab(0)">
            <div class="row wrapper-y-sm">
                <div class="operate-bar col-xs-4 font-0">
                    <button class="btn btn-operate" ng-click="batchDel()" ng-disabled="!btnPermission.giftOrderDel"
                        title="{{!btnPermission.giftOrderDel?'无权限执行此操作':''}}">删除</button>
                </div>
                <div class="search-bar wrapper-none col-xs-8">
                    <div class="btn-group m-l-xs pull-right">
                        <button type="button" class="btn btn-default base-color" ng-click="search()" title="刷新">
                            <i class="yb-icon ico-refresh"></i>
                        </button>
                        <button type="button" class="btn btn-default base-color" title="配置表格列"
                            ng-click="switchToolbar('ColConfig');">
                            <i class="yb-icon ico-set"></i>
                        </button>
                        <!-- <div class="btn btn-default base-color" ng-if="!!btnPermission.salesOrderExport">
                            <div title="导出">
                                <i class="yb-icon ico-export-o"></i>
                            </div>
                            <ul class="more-tool">
                                <li yb-download download-url="exportParam.sectionUrl"
                                    download-param="exportParam.sectionParam" download-key="ids">
                                    <i class="yb-icon ico-export-o"></i> 导出
                                </li>
                                <li yb-download download-url="exportParam.allUrl" download-param="condition">
                                    <i class="yb-icon ico-export-o"></i> 导出全部
                                </li>
                            </ul>
                        </div> -->
                    </div>
                    <button class="btn-advance pull-right m-l-xs"
                        ng-click="switchToolbar('AdvanceSearch')">高级搜索</button>
                    <div class="input-group pull-right clearfix">
                        <input type="text" class="form-control txt-search" placeholder="客户名称/手机号"
                            ng-model="condition.nameOrPhoneNo">
                        <span class="input-group-addon cursor-pointer" ng-click="search(1)">搜索</span>
                    </div>
                </div>
            </div>
            <div yb-advance-search show-toolbar="toolbarConfig.showAdvanceSearch" search-data="search(1)"
                reset-data="reset()">
                <div class="advance-search m-t-sm">
                    <div class="form-group clearfix">
                        <label class="control-label">客户名称/手机号：</label>
                        <textarea ng-model="condition.nameOrPhoneNo" class="form-control"
                            placeholder="逗号分隔或者换行分隔"></textarea>
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">兑换订单号：</label>
                        <input type="text" ng-model="condition.exchangeNo" class="form-control">
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">机型：</label>
                        <input type="text" ng-model="condition.machineType" class="form-control">
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">机号：</label>
                        <input type="text" ng-model="condition.vinCode" class="form-control">
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">创建人：</label>
                        <input type="text" ng-model="condition.createName" class="form-control">
                    </div>
                    <div class="form-group clearfix m-b-none">
                        <label class="control-label">制单时间：</label>
                        <input type="text" class="form-control date-picker" ng-model="condition.createTimeStart"
                               datepicker-popup="{{'yyyy-MM-dd'}}" ng-click="switchDataPicker(0)" is-open="datePickerFlag[0]" close-text="关闭"
                               ng-change="checkDate(condition, 'createDateStart', 'createDateEnd')" modal-size="small" readonly>
                    </div>
                    <div class="form-group clearfix m-b-none">
                        <label class="control-label"></label>
                        <label class="control-label wave-line">~</label>
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label"></label>
                        <input type="text" class="form-control date-picker" ng-model="condition.createTimeEnd"
                               datepicker-popup="{{'yyyy-MM-dd'}}" ng-click="switchDataPicker(1)" is-open="datePickerFlag[1]" close-text="关闭"
                               ng-change="checkDate(condition, 'createDateStart', 'createDateEnd')" modal-size="small" readonly>
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">创建出库单状态：</label>
                        <select name="createOutboundStatus" class="form-control" ng-model="condition.createOutboundStatus"
                                ng-options="item.id as item.name for item in createOutboundStatus">
                            <option value="">请选择</option>
                        </select>
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">出库状态：</label>
                        <select name="outboundStatus" class="form-control" ng-model="condition.outboundStatus"
                                ng-options="item.id as item.name for item in outboundStatus">
                            <option value="">请选择</option>
                        </select>
                    </div>
                </div>
            </div>
            <div yb-col-config show-toolbar="toolbarConfig.showColConfig" ng-model="tableConfig" col-fixed="true"
                has-check-col="true" set-tb-style="setFixedWidth()"></div>
            <div class="main-area">
                <div yb-table-fixed class="table-fixed-wrap fix-left" ele-count="4" scroll-area="right">
                    <div class="th-fixed">
                        <table class="table-fixed border-none" width="{{tableConfig.fixedWidth}}">
                            <thead>
                                <tr>
                                    <th width="40" class="text-center th-check border-l-none">
                                        <div yb-check-box yb-checked="markInfo.allCheckedBill"
                                            yb-click="selectAll(dataList, 'Bill')"></div>
                                    </th>
                                    <th ng-repeat="itemCol in tableConfig.tableCol track by $index"
                                        width="{{itemCol.width}}" ng-click="toSort(tableConfig.tableCol, $index)"
                                        ng-show="!!itemCol.isShow && !!itemCol.isFixed">
                                        <div yb-thead-operate ng-model="itemCol" target-width="tableConfig.fixedWidth"
                                            fixed-width="tbStyle.billFixedWidth"></div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="th-scroll-x" ng-style="tbStyle.billFixedWidth">
                        <table class="table-fixed border-none" width="{{tableConfig.scrollWidth}}">
                            <thead>
                                <tr>
                                    <th ng-repeat="itemCol in tableConfig.tableCol track by $index"
                                        width="{{itemCol.width}}" ng-click="toSort(tableConfig.tableCol, $index)"
                                        ng-show="!!itemCol.isShow && !itemCol.isFixed">
                                        <div yb-thead-operate ng-model="itemCol" target-width="tableConfig.scrollWidth">
                                        </div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll-y" ng-show="dataList.length > 0">
                        <table class="table-fixed border-none" width="{{tableConfig.fixedWidth}}">
                            <tbody>
                                <tr ng-repeat="item in dataList track by $index"
                                    ng-class="{'row-selected': $index === markInfo.cueRow}"
                                    ng-click="selectRow($index)">
                                    <td width="40" class="text-center border-l-none">
                                        <div yb-check-box yb-checked="item.isChecked"
                                            yb-click="selectSingle(item, dataList, 'Bill')"></div>
                                    </td>
                                    <td class="spill-dots" ng-repeat="itemCol in tableConfig.tableCol track by $index"
                                        width="{{itemCol.width}}" ng-show="!!itemCol.isShow && !!itemCol.isFixed"
                                        title="{{item[itemCol.dataField]}}">
                                        <span
                                            ng-if="!itemCol.clickFn && itemCol.type !== 'operate'">{{item[itemCol.dataField]}}</span>
                                        <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)"
                                            ng-if="!!itemCol.clickFn">
                                            {{item[itemCol.dataField]}}
                                        </a>
                                        <div class="font-0" ng-if="itemCol.type === 'operate'">
                                            <button type="button" class="btn btn-operate m-r-xs"
                                                ng-click="editApply(item)"
                                                ng-disabled="!btnPermission.giftOrderEdit || item.status !=0"
                                                title="{{!btnPermission.giftOrderEdit?'无权限执行此操作':''}}">编辑</button>
                                            <button type="button" class="btn btn-operate m-r-xs"
                                                ng-click="delApply(item.id)"
                                                ng-disabled="!btnPermission.giftOrderDel || item.createOutboundStatus !=0"
                                                title="{{!btnPermission.giftOrderDel?'无权限执行此操作':''}}">删除</button>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="dataList.length > 0" ng-style="tbStyle.billFixedWidth">
                        <table class="table-fixed border-none" width="{{tableConfig.scrollWidth}}">
                            <tbody>
                                <tr ng-repeat="item in dataList track by $index"
                                    ng-class="{'row-selected': $index === markInfo.cueRow}"
                                    ng-click="selectRow($index)">
                                    <td class="spill-dots" ng-repeat="itemCol in tableConfig.tableCol track by $index"
                                        width="{{itemCol.width}}" ng-show="!!itemCol.isShow && !itemCol.isFixed"
                                        title="{{item[itemCol.dataField]}}">
                                        <span
                                            ng-if="!itemCol.clickFn && itemCol.type !== 'operate'">{{item[itemCol.dataField]}}</span>
                                        <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)"
                                            ng-if="!!itemCol.clickFn">
                                            {{item[itemCol.dataField]}}
                                        </a>
                                        <div class="font-0" ng-if="itemCol.type === 'operate'">
                                            <button type="button" class="btn btn-operate m-r-xs"
                                                ng-click="editApply(item)"
                                                ng-disabled="!btnPermission.giftOrderEdit || item.status !=0"
                                                title="{{!btnPermission.giftOrderEdit?'无权限执行此操作':''}}">编辑</button>
                                            <button type="button" class="btn btn-operate m-r-xs"
                                                ng-click="delApply(item.id)"
                                                ng-disabled="!btnPermission.giftOrderDel || item.createOutboundStatus !=0"
                                                title="{{!btnPermission.giftOrderDel?'无权限执行此操作':''}}">删除</button>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="dataList.length === 0">暂时没有数据</div>
                </div>
            </div>
            <div class="bottom-area page-bar wrapper-y-sm clearfix">
                <div yb-check-box class="m-t-xs m-r-sm" yb-checked="markInfo.allCheckedBill" yb-check-name="全选"
                    yb-click="selectAll(dataList, 'Bill')"></div>
                <button class="btn btn-operate" ng-click="batchDel()" ng-disabled="!btnPermission.giftOrderDel"
                    title="{{!btnPermission.giftOrderDel?'无权限执行此操作':''}}">删除</button>
                <div yb-page-info ng-model="pageInfo" yb-refresh="search()"></div>
            </div>
        </div>
        <div tab heading="{{tabFlag.name}}" active="activeFlag[2]" ng-if="activeFlag[2]">
            <form name="orderForm" class="m-t-sm form-horizontal form-up-tb border-b clearfix" novalidate>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100"><i>*</i>订单类型：</label>
                    <div class="col-xs-8 wrapper-none">
                        <label class="col-xs-8 control-label p-l-n text-left spill-dots">
                            赠送
                        </label>
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100"><i>*</i>客户名称：</label>
                    <div class="col-xs-8 wrapper-none">
                        <label class="col-xs-8 control-label p-l-n text-left spill-dots">
                            {{orderObj.customerName}}
                        </label>
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100"><i>*</i>机型：</label>
                    <div class="col-xs-8 wrapper-none">
                        <label class="col-xs-8 control-label p-l-n text-left spill-dots">
                            {{orderObj.machineType}}
                        </label>
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100"><i>*</i>兑换车号：</label>
                    <div class="col-xs-8 wrapper-none">
                        <label class="col-xs-8 control-label p-l-n text-left spill-dots">
                            {{orderObj.vinCode}}
                        </label>
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">赠送额度：</label>
                    <div class="col-xs-8 wrapper-none">
                        <label class="col-xs-8 control-label p-l-n text-left spill-dots">
                            {{orderObj.giftAmount}}
                        </label>
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">剩余额度：</label>
                    <div class="col-xs-8 wrapper-none">
                        <label class="col-xs-8 control-label p-l-n text-left spill-dots">
                            {{orderObj.residueAmount}}
                        </label>
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">订单总额：</label>
                    <div class="col-xs-8 wrapper-none">
                        <label class="col-xs-8 control-label p-l-n text-left spill-dots">
                            {{orderObj.totalAmount}}
                        </label>
                    </div>
                </div>
            </form>
            <div class="row wrapper-y-xs">
                <div class="col-xs-12 operate-bar font-0">
                    <button class="btn btn-operate m-r-sm" ng-click="selMateriel($event)">选择零件</button>
                    <button class="btn btn-operate m-r-sm" ng-click="importMateriel()">导入零件</button>
                    <button class="btn btn-operate m-r-sm" ng-click="batchDelMateriel()">批量删除</button>
                </div>
            </div>
            <div materiel-selector show-toolbar="toolbarConfig.showMateriel" selected-list="orderObj.details"></div>
            <div class="main-area d-b-60" ng-style="{top:'180px'}">
                <div yb-table-fixed class="table-fixed-wrap">
                    <div class="th-scroll-x">
                        <table class="table-fixed border-none" width="{{materielTableConfig.scrollWidth}}">
                            <thead>
                                <tr>
                                    <th width="40" class="th-check text-center">
                                        <div yb-check-box yb-checked="markInfo.allCheckedMaterial"
                                            yb-click="selectAll(orderObj.details, 'Material')"></div>
                                    </th>
                                    <th width="60">
                                        操作
                                    </th>
                                    <th ng-repeat="itemCol in materielTableConfig.tableCol track by $index"
                                        width="{{itemCol.width}}" ng-if="!itemCol.hidden">
                                        <div yb-thead-operate ng-model="itemCol"
                                            target-width="materielTableConfig.scrollWidth"></div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="orderObj.details.length > 0">
                        <table class="table-fixed border-none" width="{{materielTableConfig.scrollWidth}}">
                            <tbody>
                                <tr ng-repeat="item in orderObj.details track by $index ">
                                    <td width="40" class="text-center">
                                        <div yb-check-box yb-checked="item.isChecked"
                                            yb-click="selectSingle(item, orderObj.details, 'Material')"></div>
                                    </td>
                                    <td width="60">
                                        <button type="button" class="btn btn-operate"
                                            ng-click="delMateriel(item, $index, $event)">删除</button>
                                    </td>
                                    <td ng-repeat="itemCol in materielTableConfig.tableCol track by $index"
                                        width="{{itemCol.width}}" ng-if="!itemCol.hidden"
                                        ng-class="{'wrapper-none': false}">
                                        <div class="spill-dots" ng-if="!itemCol.input"
                                            title="{{item[itemCol.dataField]}}">
                                            <span ng-if="!itemCol.clickFn">
                                                {{item[itemCol.dataField]}} 
                                            </span>
                                        </div>
                                        <div ng-if="itemCol.input && itemCol.inputType === 'num'" class="td-edit pos-r"
                                            title="{{item[itemCol.dataField]}}">
                                            <input type="text" class="form-control edit"
                                                ng-model="item[itemCol.dataField]"
                                                ng-change="setNum(item, itemCol.dataField)" yb-number-input
                                                disable-decimal="false" decimal-places="3" max="99999999.999">
                                            <div class="pos-a tool-tips" ng-if="!!item.numErr">
                                                <i class="triangle"></i>
                                                <div class="msg">申请数量不能为空</div>
                                            </div>
                                        </div>
                                        <!-- <div ng-if="itemCol.input && itemCol.inputType === 'price'"
                                            class="td-edit pos-r" title="{{item[itemCol.dataField]}}">
                                            <input type="text" class="form-control edit"
                                                ng-model="item[itemCol.dataField]"
                                                ng-change="setAdjustPrice(item, itemCol.dataField)" yb-number-input
                                                disable-decimal="false" decimal-places="2" max="99999999.99"
                                                ng-class="{'error': item.priceAdjustErr}">
                                            <div class="pos-a tool-tips" ng-if="!!item.priceAdjustErr">
                                                <i class="triangle"></i>
                                                <div class="msg">调整后单价不能为空和0</div>
                                            </div>
                                        </div> -->

                                        <div ng-if="itemCol.input && itemCol.inputType === 'checkbox'"
                                            class="text-center">
                                            <div yb-check-box yb-checked="item['isChecked']"
                                                yb-click="checkItem(item, itemCol.dataField)"></div>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="orderObj.details.length === 0">暂时没有数据
                    </div>
                </div>
            </div>
            <div class="bottom-area btn-bar text-center clearfix">
                <button type="button" class="btn btn-primary m-r-sm" ng-if="tabFlag.type === 1"
                    ng-click="saveData(orderForm.$valid,submitEnum.Save)">保存</button>
                <button type="button" class="btn btn-primary m-r-sm" ng-if="tabFlag.type === 1"
                    ng-click="saveData(orderForm.$valid,submitEnum.Submit)">提交</button>
                <button type="button" class="btn btn-primary m-r-sm" ng-if="tabFlag.type === 2"
                    ng-click="saveData(orderForm.$valid,submitEnum.Save)">保存</button>
                <button type="button" class="btn btn-primary m-r-sm" ng-if="tabFlag.type === 2"
                    ng-click="saveData(orderForm.$valid,submitEnum.Submit)">提交</button>
                <button type="button" class="btn btn-default" ng-click="cancel()">取消</button>
            </div>
        </div>
        <div tab heading="详情" active="activeFlag[3]" ng-if="activeFlag[3]">
            <div class="m-t-sm form-up-tb clearfix">
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">订单类型：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.billType}}">
                        赠送
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">客户名称：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.customerName||'-'}}">
                        {{orderObj.customerName||'-'}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">机型：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.machineType||'-'}}">
                        {{orderObj.machineType || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">兑换车号：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.vinCode||'-'}}">
                        {{orderObj.vinCode||'-'}}
                    </div>
                </div>

                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">赠送额度：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.giftAmount||'-'}}">
                        {{orderObj.giftAmount||'-'}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">剩余额度：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.residueAmount ||'-'}}">
                        {{orderObj.residueAmount || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">订单总额：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.totalAmount ||'-'}}">
                        {{orderObj.totalAmount || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">已建出库金额：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.createdOutPrice ||'-'}}">
                        {{orderObj.createdOutPrice || "-"}}
                    </div>
                </div>
            </div>
            <div class="main-area d-b-60" ng-style="{'top': '110px'}">
                <div yb-table-fixed class="table-fixed-wrap">
                    <div class="th-scroll-x">
                        <table class="table-fixed border-none" width="{{materielTableConfig.scrollWidth}}">
                            <thead>
                                <tr>
                                    <th ng-repeat="itemCol in materielTableConfig.tableCol track by $index"
                                        width="{{itemCol.width}}" ng-if="itemCol.type!=='cost'||costPriceShow">
                                        <div yb-thead-operate ng-model="itemCol"
                                            target-width="editMaterielConfig.scrollWidth"></div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="orderObj.details.length > 0">
                        <table class="table-fixed border-none" width="{{materielTableConfig.scrollWidth}}">
                            <tbody>
                                <tr ng-repeat="item in orderObj.details track by $index">
                                    <td class="spill-dots"
                                        ng-repeat="itemCol in materielTableConfig.tableCol track by $index"
                                        width="{{itemCol.width}}" title="{{item[itemCol.dataField]}}"
                                        ng-if="itemCol.type!=='cost'||costPriceShow">
                                        {{item[itemCol.dataField]}}
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="orderObj.details.length === 0">暂时没有数据
                    </div>
                </div>
            </div>
            <div class="bottom-area btn-bar text-center clearfix">
                <button type="button" class="btn btn-default" ng-click="cancel()">返回</button>
            </div>
        </div>
    </div>
</div>
